/*
 *	OpenSource code or fragments by agile webentwicklung, Marcus Fuhrmeister
 *
 *	Redistribution and use in source and binary forms, with or without
 *	modification, are permitted provided that the following conditions
 *	are met:
 *  
 *		* Redistribution of source code must retain the above OpenSource comment,
 *		this list of conditions and the following disclaimer.
 * 
 *		* Redistribution in binary form must reproduce the above OpenSource comment,
 *		this list of conditions and the following disclaimer in the
 *		documentation and/or other materials provided with the distribution.
 * 
 *	Neither the name of 'avocaod systems, Marcus Fuhrmeister' or the
 *	names of contributors may be used to endorse or promote products derived
 *	from this software without specific prior written permission.
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
 */
package de.fuhrmeister.browserchooser.model;

import java.util.ArrayList;

/**
 * Browser model class holding several browser version models.
 * 
 * @date 20.11.2008
 * @author Marcus Fuhrmeister
 */
public class BrowserModel extends ArrayList<BrowserVersionModel> implements java.io.Serializable, Comparable<BrowserModel> {

	private static final long serialVersionUID = -401655633365696467L;
	private String icon;
	private String name;
	private int ID;

	/**
	 * Returns the browser icon.
	 * 
	 * @return the browser icon
	 */
	public String getIcon() {
		return icon;
	}

	/**
	 * Returns the browser name.
	 * 
	 * @return the browser name
	 */
	public String getName() {
		return name;
	}

	/**
	 * Returns the browser id.
	 * 
	 * @return the browser id
	 */
	public int getID() {
		return ID;
	}

	/**
	 * Sets the browser icon.
	 */
	public void setIcon(final String icon) {
		this.icon = icon;
	}

	/**
	 * Sets the browser name.
	 */
	public void setName(final String name) {
		this.name = name;
	}

	/**
	 * Sets the browser id.
	 */
	public void setID(final int ID) {
		this.ID = ID;
	}

	/**
	 * Compares the given browser model with this model by comparing it`s ids.
	 * 
	 * @return  0 if the given model has the same id as this model, -1 if the given model has a higher id than this model, 1 if the given model has a lower id than this model
	 */
	public int compareTo(final BrowserModel o) {
		if (this.getID() == o.getID()) {
			return 0;
		}
		if (this.getID() < o.getID()) {
			return -1;
		} else {
			return 1;
		}
	}

	/**
	 * Compares the given object with this model by id.
	 * 
	 * @return true if the given object is an instance of <code>BrowserModel</code> and has the same id as this model
	 */
	@Override
	public boolean equals(final Object o) {
		if (o instanceof BrowserModel) {
			return this.getID() == ((BrowserModel) o).getID() ? true : false;
		}
		return false;
	}
}
